<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function getL() {
            var str = '';
            for (var i = 0; i < 26; i++) {
                str += String.fromCharCode(97 + i);
            }
            for (var i = 0; i < 26; i++) {
                str += String.fromCharCode(65 + i);
            }
            return str;
        }

        function l_ramdom(n) {
            var str = getL();
            var n_str = '';
            for (var i = 0; i < n; i++) {
                n_str += str.charAt(Math.floor(Math.random() * str.length));
            }
            return n_str;
        }
        console.log(l_ramdom(3));
        document.write(l_ramdom(5));
    </script>
</body>

</html>